//指针与数组与函数

#include<iostream>
#include<string.h>

using namespace std;

void bubbleSort(int* arr, int len)
{
	for (int i = 0; i < len - 1; i++)
	{
		for (int j = 0; j < len - 1 - i; j++)
		{
			if (arr[j] > arr[j + 1])
			{
				int temp = arr[j];
				arr[j] = arr[j + 1];
				arr[j + 1] = temp;
			}
		}
	}
}

void printArray(int* arr, int len)
{
	for (int i = 0; i < len; i++) {
		cout << arr[i] << " ";
	}
}

int main()
{
	int arr[] = { 4,2,6,8,1,9,7,3,5 };
	int len = sizeof(arr) / sizeof(arr[0]);
	bubbleSort(arr, len);
	
	printArray(arr, len);
	system("pause");
	return 0;
}